 <%-- 
    Document   : pertanyaan_tawaran
    Created on : Aug 9, 2012, 9:31:25 AM
    Author     : faizal.azlee(Theta-Edge Bhd)
--%>
<%@ include file="/WEB-INF/jsp/include/page_header.jspf" %>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Pendaftaran Haji</title>        
    
    <!--<body>--> 
    <script type="text/javascript">            
        var mygridHReg;
        var runid_HReg = 0;
        var dp_HReg;
        var xwin = new Array();
        xwin[0] = null;

        $(document).ready(function(){
            $('form').submit( 
                function () {
                    return formValidation();
                }
            );  
            initDhxWins();
            prepareGridHReg();              
            }
        );    
        
        //define dhtmlx grid
        function prepareGridHReg()
        {
            mygridHReg = new dhtmlXGridObject('gridHReg');
            mygridHReg.setImagePath("<%=request.getContextPath()%>/resources/codebase/imgs/");
            mygridHReg.setSkin("modern");
            mygridHReg.enableMultiline(true);
            //mygridHReg.enableAutoHeight(true);
            mygridHReg.init();

            dp_HReg = new dataProcessor("<%=request.getContextPath()%>/resources/xml/dp.jsp");
            dp_HReg.setUpdateMode("off");
            dp_HReg.setTransactionMode("POST",true);
            dp_HReg.init(mygridHReg);            
            loadGridHReg();           
        }
        
        var gridHRegLoaed = false;
        function loadGridHReg()
        {            
            if(gridHRegLoaed) return;
            gridHRegLoaed = true; 
            mygridHReg.loadXML("<%=request.getContextPath()%>/resources/xml/hajjregxml.jsp", doAfterLoadgridHReg);            
        }

        function doAfterLoadgridHReg(){
            //after load
         }
            
        var dhxWins;
        var dhxpopup;
        //define dhtmlx popup window
        function initDhxWins()
        {
            dhxWins = new dhtmlXWindows();
            dhxWins.setImagePath("<%=request.getContextPath()%>/resources/codebase/imgs/");
            dhxWins.enableAutoViewport(false);
            dhxWins.attachViewportTo("detail-div");
             
            dhxpopup = new dhtmlXWindows();
            dhxpopup.setImagePath("<%=request.getContextPath()%>/resources/codebase/imgs/");
            dhxpopup.enableAutoViewport(false);
            dhxpopup.attachViewportTo("detail-div");
        }
        
        //popup window and add member into grid
        var winObj
        function goAddNewMember(noAkaunPenambah){            
            var gsize = mygridHReg.getRowsNum();
            if(gsize>=10){
                alert("Had maksimum pendaftaran haji adalah seramai 10 orang");
                return true;
            }
                
            if(!dhxWins.isWindow('plusW')){
                winObj = dhxWins.createWindow("plusW", 445, 455, 550, 300);
                //winObj.hideHeader();
                winObj.setText("");
                //winObj.button('minmax1').hide();
                //winObj.button('minmax2').hide();
                //winObj.button('park').hide();
//                winObj.button('close').hide();
                winObj.setModal(true);
                winObj.denyMove();
                //winObj.hideHeader();
                winObj.attachURL('<%=request.getContextPath()%>/haji/registration?showPopupTambahAhli&noAkaunPenambah='+noAkaunPenambah, false);
                //winObj.centerOnScreen();
            }
        }

        function changeWinDimension(){
            dhxWins.window('plusW').setDimension(550, 600);
        }
       
        //edit member in grid
        function goEditDetails(id, isPrimary){
            if(!dhxWins.isWindow('plusW'))
                {
                var winObj = dhxWins.createWindow("plusW", 445, 455, 550, 600);
                //winObj.hideHeader();
                winObj.setText("");
                //winObj.button('minmax1').hide();
                //winObj.button('minmax2').hide();
                //winObj.button('park').hide();
                winObj.setModal(true); 
                //winObj.centerOnScreen();
                winObj.denyMove();
                //winObj.hideHeader();
                winObj.attachURL('<%=request.getContextPath()%>/haji/registration?showPopupEditmembers&id='+id+'&isPrimary='+isPrimary, false);
            }  
        }
        
        function chekDup(accountNo){
           var rowIds = mygridHReg.getAllRowIds();
           if(rowIds != null && rowIds != '')
           {
                var ids = rowIds.split(',');                
                for(var i=0; i<ids.length; i++)
                {
                    var comparedAccountNo = mygridHReg.cells(ids[i],2).getValue().trim();                    
                    if(accountNo.trim() == comparedAccountNo){
                        return false;
                        break;
                    }
                }
           }
           return true;
        }
        
        function goDeleteMember(id, idPenambah){
            var url = "${pageContext.request.contextPath}/haji/registration?deleteMember&id="+id+"&idPenambah="+idPenambah;
            //animateSaving(true);
            $.ajax({
                    url : url,
                    dataType : "html",  
                    data: "",
                    type: "post",
                    success: function(data) {
                        gridHRegLoaed = false;
                        loadGridHReg();
                        //endAnimation();
                    }
                    ,
                    error : function() {
//                            alert("Sorry, The requested property could not be found.");
                    }
            });
        }
        
        function redirectToHomePage(f){
            var url = '${pageContext.request.contextPath}/haji?showMainForm';
            f.action = url;
            f.submit();
        }

    </script>
    </head>
 
    <body>   
        <s:messages/>
        <s:errors/> 
        <br/>
        <s:form beanclass="th.stripes.action.HajiRegistrationActionBean" class="niceform">
            <s:hidden name="haji.noAkaun" id="noAkaun"/>
            <div id="content">
                <div id="logo">
                    <span>
                        <img src="${pageContext.request.contextPath}/images/img/ribbon.png"/>               
                    </span>
                </div>
                <h3>
                    Pendaftaran Haji
                </h3>
                <div>
                    <input type="hidden" id="deleteMemberIds">
                    <div id="gridHReg" style="width:100%; height:200px; background-color:white; z-index: -2"></div>
                </div>
                <p>
                    <font size="2">
                    Had maksima pendaftaran haji adalah seramai 10 orang. Sila klik ‘+’ untuk menambah senarai pendaftaran. Sila klik Daftar untuk meneruskan pendaftaran haji. 
                    </font>
                </p>
                <br>
                <p align="center">
                    <s:button name="halamutama" value="Halaman Utama" onclick="redirectToHomePage(this.form);" class="button green"/> 
                    <s:submit name="batalPendaftaranHaji" value="Batal" id="batalPendaftaran" class="button green button_blockUI"/> 
                    <s:submit name="HajjReg_Step5" value="Daftar" class="button green button_blockUI"/>
                </p>           
            </div>
        </s:form>            
    </body>    
</html>
